Skip to content

Runtime: Expose readonly directly off the datastore runtime #24410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Apr 23, 2025

Conversation

anthony-murphy
Copy link
Contributor

@anthony-murphy anthony-murphy commented Apr 21, 2025

This change plumbs through the readonly flag from the container runtime to the data store runtime. This will reduce reliance on the delta manager in datastores as one of the primary reasons it is used is to retrieve the readonly flag. In addition to the flag, this change also propagates the readonly event, so changes can be detected.

In order to be backward compatible, there is code in the DataStoreContext which ensures that the readonly flag is correctly set for older data stores. In the FluidDataStoreRuntime this is code to handle context's which do and don't support setting readonly. These together ensure a consistent experience for developers, regardless of the versions they are using.

The primary motivation for this change is to leverage readonly to deal with back and forward compat between layers, as we can build upon this to support putting specific datastore into readonly if they do not support some feature. I plan to leverage this for staging mode, so datastores which should not submit changes during staging mode, can be placed in readonly.

AB#32463

@github-actions github-actions bot added base: main PRs targeted against main branch area: runtime Runtime related issues area: tests Tests to add, test infrastructure improvements, etc public api change Changes to a public API labels Apr 21, 2025
@github-actions github-actions bot added area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct and removed area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct labels Apr 21, 2025
@github-actions github-actions bot added the area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct label Apr 21, 2025
@anthony-murphy anthony-murphy marked this pull request as ready for review April 22, 2025 00:51
@Copilot Copilot AI review requested due to automatic review settings April 22, 2025 00:51
@anthony-murphy anthony-murphy requested a review from a team as a code owner April 22, 2025 00:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR exposes the datastore runtime’s readonly flag and readonly event from the container runtime to reduce reliance on the delta manager. Key changes include adding a new feature constant (setReadonly) in the runtime definitions, propagating the readonly event in the FluidDataStoreRuntime, and updating tests and compatibility checks accordingly.

Reviewed Changes

Copilot reviewed 27 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/runtime/runtime-definitions/src/runtimeLayerCompatFeatureNames.ts Added a new constant (setReadonly) to expose readonly functionality.
packages/runtime/runtime-definitions/src/index.ts Updated exports to include the new setReadonly feature.
packages/runtime/runtime-definitions/src/dataStoreContext.ts Added optional setReadOnlyState method and readonly flag to context interfaces.
packages/runtime/datastore/src/dataStoreRuntime.ts Implemented a getter for readonly and setReadOnlyState to propagate updates.
packages/runtime/container-runtime/src/dataStoreContext.ts Introduced ContextDeltaManagerProxy to shim readonly state for backward compatibility.
Other test and API-report files Updated to include the new readonly functionality and compatibility markers.
Files not reviewed (2)
  • packages/framework/aqueduct/package.json: Language not supported
  • packages/runtime/datastore/package.json: Language not supported
Comments suppressed due to low confidence (1)

packages/runtime/runtime-definitions/src/runtimeLayerCompatFeatureNames.ts:18

  • [nitpick] The naming for the readonly feature is inconsistent with other related methods (e.g. setReadOnlyState, get readonly) where 'ReadOnly' is camel-cased. Consider renaming the constant to 'setReadOnly' for consistency.
export const setReadonly = "setReadonly" as const;

Co-authored-by: Mark Fields <markfields@users.noreply.github.com>
Copy link
Member

@markfields markfields left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@anthony-murphy anthony-murphy force-pushed the ro/datastore-readonly branch from 3f52a4f to 0b0ccc3 Compare April 23, 2025 20:59
@anthony-murphy anthony-murphy force-pushed the ro/datastore-readonly branch from 0b0ccc3 to c27695d Compare April 23, 2025 21:01
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> fluid-framework-docs-site@0.0.0 ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> fluid-framework-docs-site@0.0.0 serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> fluid-framework-docs-site@0.0.0 check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  163679 links
    1315 destination URLs
    1547 URLs ignored
       0 warnings
       0 errors


Copy link
Contributor

@ChumpChief ChumpChief left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plumbing across layers is a bit painful (i.e. taking different shapes, mechanisms, optionalities, etc.) but I don't think significantly moreso than for connection state. Not sure what the solution looks like, but I suppose if we manage to solve it for one we'll solve it for the other too.

@anthony-murphy anthony-murphy enabled auto-merge (squash) April 23, 2025 22:49
@anthony-murphy anthony-murphy merged commit e991905 into microsoft:main Apr 23, 2025
39 checks passed
@anthony-murphy anthony-murphy deleted the ro/datastore-readonly branch April 23, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct area: runtime Runtime related issues area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants